package org.holynite.fieldmanage.entities

import org.hibernate.annotations.GenericGenerator
import org.holynite.fieldmanage.types.Privileges

import javax.persistence.Basic
import javax.persistence.CascadeType
import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.FetchType
import javax.persistence.GeneratedValue
import javax.persistence.Id
import javax.persistence.JoinColumn
import javax.persistence.JoinTable
import javax.persistence.Lob
import javax.persistence.ManyToMany
import javax.persistence.OneToMany
import javax.persistence.Table
import javax.persistence.Transient

/**
 * Created by midnite on 15/1/3.
 */
@Entity
@Table(name = "supervisor_role")
class AdministratorRole implements Serializable {
	@Id
	@Column(name = "svr_id")
	@GeneratedValue(generator = "svr-gen")
	@GenericGenerator(name = "svr-gen", strategy = "uuid")
	String svrid
	@Column(name = "role_name", nullable = false, length = 30)
	String role
	@Transient
	List<RolePrivilege> privileges

	boolean equals(o) {
		if (this.is(o)) return true
		if (getClass() != o.class) return false

		AdministratorRole that = (AdministratorRole) o

		if (svrid != that.svrid) return false

		return true
	}

	int hashCode() {
		return (svrid != null ? svrid.hashCode() : 0)
	}
}
